
$().ready(function() {
    validateRule();
    layui.use(['form','laydate','table'], function() {
        var laydate = layui.laydate;
        //日期时间选择器
        laydate.render({
            elem: '#repairTime'
            ,type: 'datetime'
        });
    });
});


$.validator.setDefaults({
    submitHandler : function() {
        update();
    }
});

function validateRule() {
    var icon = "<i class='fa fa-times-circle'></i> ";
    $("#signupForm").validate({
        rules : {
            repairName:{  required : true  },
            repairTime : { required : true  },
            repairState : { required : true  },
        },
        messages : {
            repairName : {
                required : icon + "请输入处理人员姓名"
            },
            repairTime : {
                required : icon + "请输入处理时间"
            },
            repairState : {
                required : icon + "请选择处理状态"
            },
        }
    })
}

function update() {
    var url = ctx + "module/terminal/repair/update";
    $.ajax({
        cache : true,
        type : "POST",
        url : url,
        data : $('#signupForm').serialize(),// 你的formid
        async : false,
        error : function(request) {
            parent.layer.alert("Connection error");
        },
        success : function(data) {
            if (data.code == 0) {
                parent.layer.msg("操作成功");
                parent.reLoad();
                var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                parent.layer.close(index);

            } else {
                parent.layer.alert(data.msg)
            }
        }
    });

}
